import 'package:boss/models/necessary_order.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:boss/ui/widget/radioList/radio.dart' as radio;
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class NecessaryOrderItem extends StatelessWidget {
  final NecessaryOrder data;
  final VoidCallback onTap;
  final VoidCallback onEdit;

  const NecessaryOrderItem({
    Key key,
    @required this.data,
    this.onTap,
    this.onEdit,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: ShadowRadiusCard(
        margin: EdgeInsets.only(
          bottom: 30.w,
        ),
        padding: EdgeInsets.symmetric(
          horizontal: 30.w,
          vertical: 30.w,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Row(
              children: <Widget>[
                radio.Radio(
                  isSelected: data.isUseStatus,
                ),
                Container(
                  margin: EdgeInsets.only(
                    left: 20.w,
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        data.necessaryName,
                        style: TextStyleConstant().normal_1_32,
                      ),
                      Container(
                        margin: EdgeInsets.only(
                          top: ScreenUtil.instance.setWidth(12.5),
                        ),
                        child: RichText(
                          text: TextSpan(
                            text: '${AmountUtil.price2String(data.price)} x ${data.everyoneCount}${data.unit}',
                            style: TextStyleConstant().origin_28,
                            children: [
                              TextSpan(
                                text: '/${data.chargingModeString}',
                                style: TextStyleConstant().normal_3_24,
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                )
              ],
            ),
            GestureDetector(
              onTap: onEdit,
              child: BaseImage(
                'assets/image/edit2_icon.png',
                width: 44.w,
                height: 44.w,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
